package com.ybdz.scanner.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ybdz.scanner.R;
import com.ybdz.scanner.base.BaseAdapter;
import com.ybdz.scanner.bean.chuKuBean;
import com.ybdz.scanner.utils.UIUtils;

import java.util.List;

/**
 * @ClassName: luKuLiShiAdapter
 * @author: zhao
 * @date 2018/1/20 15:16
 */
public class chuKuLiShiAdapter extends BaseAdapter<chuKuLiShiAdapter.chuKuLiShiViewHolder> {

    private final LayoutInflater inflater;
    private List<chuKuBean> list ;

    public chuKuLiShiAdapter(Context context, List<chuKuBean> list) {
        inflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public chuKuLiShiViewHolder CreateChildViewHolder(ViewGroup parent, int viewType) {
        View view = this.inflater.inflate(R.layout.item_recycleview, parent, false);

        return new chuKuLiShiViewHolder(view);
    }

    public void setData(List<chuKuBean> data) {
        this.list = data;
    }

    @Override
    public void bindViewHolder(chuKuLiShiViewHolder holder, int position) {

        holder.mTvName.setText(String.valueOf(list.get(list.size() - position -1).getName()));
        holder.mTvWeight.setText(String.valueOf(list.get(list.size() -position-1).getWeight()));
        holder.mTvConformity.setText(String.valueOf(list.get(list.size() -position-1).getIsQualified()));

    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    class chuKuLiShiViewHolder extends BaseAdapter.BaseViewHolder{
        private final TextView mTvName;
        private final TextView mTvWeight;
        private final TextView mTvConformity;

        chuKuLiShiViewHolder(View view) {
            super(view);
            mTvName = (TextView) view.findViewById(R.id.tv_name);
            mTvWeight = (TextView) view.findViewById(R.id.tv_weight);
            mTvConformity = (TextView) view.findViewById(R.id.tv_conformity);
        }
    }
}
